package interfaz;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;

public class Web extends JDialog {
	
	private static final long serialVersionUID = 1L;
	private JPanel mainPanel;
	private JTextArea texto;
	private JButton atrasButton;


	public Web(JFrame padre) {
		super(padre,true);
        initComponents();
        pack();
        Rectangle parentBounds = padre.getBounds();
        Dimension size = getSize();
        // Center in the parent
        int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
        int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
        setLocation(new Point(x, y));
	}


	private void initComponents() {
GridBagConstraints gridBagConstraints;
		
		mainPanel = new JPanel();
		texto = new JTextArea();
		atrasButton = new JButton();
		
		getContentPane().setLayout(new GridBagLayout());

        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Reglas Link-A-Pix");
        mainPanel.setLayout(new GridBagLayout());
        
        mainPanel.setBorder(new EmptyBorder(new Insets(11, 11, 12, 12)));
        texto.setBackground(UIManager.getDefaults().getColor("Panel.background"));
        texto.setColumns(25);
        texto.setEditable(false);
        texto.setLineWrap(true);
        texto.setRows(12);
        texto.setText("Web oficial del juego:\n\nhttp://www.conceptispuzzles.com/index.aspx?uri=puzzle/link-a-pix");
        texto.setWrapStyleWord(true);
        texto.setBorder(null);
        texto.setFocusable(false);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = GridBagConstraints.NORTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new Insets(24, 0, 24, 0);
        mainPanel.add(texto, gridBagConstraints);

        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new Insets(10, 10, 10, 10);
        getContentPane().add(mainPanel, gridBagConstraints);
        
        atrasButton.setMnemonic('N');
        atrasButton.setText("Volver");
        atrasButton.setToolTipText("Volver");
        atrasButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                atrasButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
        gridBagConstraints.gridheight = GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHEAST;
        gridBagConstraints.weighty = 1.0;
        mainPanel.add(atrasButton, gridBagConstraints);

	}


	protected void atrasButtonActionPerformed(ActionEvent evt) {
		this.setVisible(false);
	}

	

}
